package com.yan.design.two.behavior.s7;

/**
 * 7. 备忘录模式
 *      测试
 * @author shengren.yan
 * @create 2022-08-13
 */
public class testRun {

    public static void main(String[] args) {
        // 创建角色
        GameRole g1 = new GameRole();
        g1.setVit(100);
        g1.setDet(100);

        System.out.println("初始状态");
        g1.getPlay();

        // 保存当前状态
        Caretaker caretaker = new Caretaker();
        caretaker.setMediator(g1.createMemento());
        System.out.println("和别人大战");
        g1.setDet(30);
        g1.setVit(40);
        g1.getPlay();

        // 获得上一个状态
        g1.recoverGame(caretaker.getMemento());
        System.out.println("恢复后的状态");
        g1.getPlay();

    }
}
